package com.shr.codem;

import java.util.LinkedList;
import java.util.Scanner;

public class SubString {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int number = Integer.parseInt(sc.nextLine());
			String subStr = sc.nextLine();
			boolean flag = false;
				for (int rex = 2; rex <= 16; rex++) {
					StringBuffer totalStr = new StringBuffer();
					for (int i = 1; i <= number; i++) {
						String bStr = getBString(i, rex);
						totalStr.append(bStr);
					}
					if (totalStr.toString().indexOf(subStr) >= 0) {
						System.out.println("yes");
						flag = true;
						break;
					}
				}
			if (!flag)
				System.out.println("no");
		}
		sc.close();
	}

	private static String getBString(int i, int rex) {
		switch (rex) {
		case 2:
			return Integer.toBinaryString(i);
		case 8:
			return Integer.toOctalString(i);
		case 16:
			return Integer.toHexString(i);
		default:
			int temp = i;
			LinkedList<String> strList = new LinkedList<>();
			do {
				int t = temp % rex;
				char comC;
				if (t > 9) {
					int diff = 'A' - 10;
					comC = (char) (diff + t);
					strList.addFirst(comC + "");
				} else
					strList.addFirst(t + "");

				temp = temp / rex;
			} while (temp != 0);
			StringBuffer retStr = new StringBuffer();
			while (strList.size() > 0)
				retStr.append(strList.poll());
			return retStr.toString();
		}
	}
}
